<%-- 
    Document   : viewCourses
    Created on : Oct 27, 2011, 10:26:05 PM
    Author     : Quangtv
--%>

<%@page import="DTO.TeacherDTO"%>
<%@page import="java.net.URLEncoder"%>
<%@page import="BLO.SubjectBLO"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="DTO.SubjectDTO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">


<html>

    <head>
        <title>View All Courses</title>
        <meta name="description" content="website description" />
        <meta name="keywords" content="website keywords, website keywords" />
        <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
        <link rel="stylesheet" type="text/css" href="style/css/style.css" />
    </head>
    <%
                String username = (String) session.getAttribute("USERNAME");
                SubjectBLO sblo = new SubjectBLO();
                ArrayList<SubjectDTO> studentsubjectList = new ArrayList<SubjectDTO>();
                ArrayList<SubjectDTO> subjectList = new ArrayList<SubjectDTO>();
                ArrayList<SubjectDTO> teachersubjectList = new ArrayList<SubjectDTO>();
                String roleid = (String) session.getAttribute("ROLEID");
                subjectList = sblo.getAllSubjects();
                request.setAttribute("ALLLIST", subjectList);

                String role = (String) session.getAttribute("ROLE");
                if (role.equals("Student")) {
                    studentsubjectList = sblo.getStudentSubjects(roleid);
                    request.setAttribute("USERLIST", studentsubjectList);
                }
                if (role.equals("Teacher")) {
                    //implement cho giao vien o day
                    teachersubjectList = sblo.getTeacherSubjects(roleid);
                    request.setAttribute("USERLIST", teachersubjectList);
                }
    %>
    <body>
        <div id="main">
            <div id="header">
                <div id="logo">
                    <div id="logo_text">
                        <!-- class="logo_colour", allows you to change the colour of the text -->
                        <h1><a href="index.jsp">Student<span class="logo_colour">Management</span></a></h1>
                        <h2>Simple. fast. effective. </h2>
                    </div>
                </div>
                <div id="menubar">
                    <ul id="menu">
                        <!-- put class="selected" in the li tag for the selected page - to highlight which page you're on -->
                        <li  class="selected" id="person_info"><a href="Controller?Action=Logout"><%= (String) session.getAttribute("USERNAME")%> (Logout)</a></li>
                        <li><a href="index.jsp">Home</a></li>
          <li><a href="Education.jsp">Education</a></li>
          <li><a href="#">Library</a></li>
          <li><a href="Contact.jsp">Contact Us</a></li>
                    </ul>
                </div>
            </div>
            <div id="content_header"></div>
            <div id="site_content">
                <div class="sidebar">
                    <!-- insert your sidebar items here -->
                    <h3>Resources</h3>
                    <ul id="list-nav">
                        <li><a href="Controller?Action=viewCourses">Courses</a></li>
                        <li><a href="mail.fpt.edu.vn">Mail</a></li>
                        <li><a href="http://cms-hcm.fpt.edu.vn/elearning/feedback">Feedback</a></li>
                        <li><a href="schedule.jsp">Schedule</a></li>
                        <li><a href="http://msdn70.e-academy.com/elms/Storefront/Home.aspx?campus=fptuniversity_it">MSDN AA</a></li>
                        <li><a href="http://cms-hcm.fpt.edu.vn/elearning/mod/resource/view.php?id=185">Change Password</a></li>
                    </ul>
                    <p style="padding-top: 10px"><span>&nbsp;</span>
                    <!-- Sau khi &#273;ã login vào h&#7879; th&#7889;ng, show nh&#7919;ng course c&#7911;a sinh viên ho&#7863;c giáo viên -->
                    <h3>Your Courses</h3>
                    <ul>
                        <c:set var="list" value="${requestScope.USERLIST}"></c:set>
                        <c:forEach items="${list}" var="subject">
                            <li><a href="Controller?Action=ViewDetail&subjectid=${subject.strSubjectID}
                                   &subjectname=${subject.strSubjectName}
                                   &description=${subject.strDescription}"><c:out value="${subject.strSubjectName}"/></a></li>
                            </c:forEach>
                    </ul>
                    <h3>Search</h3>
                    <form method="post" action="#" id="search_form">
                        <p>
                            <input class="search" type="text" name="search_field" value="Enter keywords....." >
                            <input name="search" type="image" style="border: 0; margin: 0 0 -9px 5px;" src="style/picture/search.png" alt="Search" title="Search" >
                        </p>
                    </form>
                </div>
                <div id="content">
                    <!-- insert the page content here -->
                    <h1>All Courses</h1>
                    <table border="1" style="border-style: solid; width: 620px">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Course Name</th>
                                <th>Description</th>
                            </tr>
                        </thead>
                        <tbody>
                            <c:set var="alist" value="${requestScope.ALLLIST}"></c:set>
                            <c:set var="count" value="0"></c:set>
                            <c:forEach items="${alist}" var="asubject">
                                <tr>
                                    <td>${count + 1}</td>
                                    <td><a href="Controller?Action=ViewDetail&subjectid=${asubject.strSubjectID}
                                           &subjectname=${asubject.strSubjectName}
                                           &description=${asubject.strDescription}">${asubject.strSubjectName}</a></td>
                                    <td>${asubject.strDescription}</td>
                                    <c:set var="count" value="${count+1}"/>
                                </tr>
                            </c:forEach>
                        </tbody>
                    </table>

                </div>
            </div>
            <div id="content_footer"></div>
            <div id="footer">
                <a href="index.jsp">Home</a> | <a href="#">News</a> | <a href="#">Education</a> | <a href="#">Library</a> | <a href="contact.html">Contact Us</a>
            </div>
        </div>
    </body>
</html>
